<template>
  <h1>El组件-表格</h1>
  <el-table :data="tableData" style="width: 100%">
    <el-table-column prop="date" label="Date" width="180" />
    <el-table-column prop="name" label="Name" width="180" />
    <el-table-column prop="address" label="Address" />
  </el-table>

  <el-table :data="tableUser" style="width: 500px;margin:0 auto;">
    <el-table-column type="index" label="序号" align="center" width="80"/>
    <el-table-column prop="name" label="Name" align="center"/>
    <el-table-column prop="salary" label="Salary" align="center"/>
    <el-table-column prop="job" label="Job" align="center"/>
    <el-table-column label="操作" align="center">
      <template #default="scope">
        <el-button type="danger" size="mini" @click="delUser(scope.$index,scope.row)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>






</template>
<script setup>
import { ref } from 'vue'

const tableData = [
  {
    date: '2016-05-03',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
]

const tableUser = ref([
  {
    name: '张三',
    salary: 3000,
    job: '饲养员',
  },
  {
    name: '李四',
    salary: 4000,
    job: '护林员',
  },
  {
    name: '王五',
    salary: 5000,
    job: '销售员',
  },
  {
    name: '赵六',
    salary: 6000,
    job: '程序员',
  }
])

const delUser = (index,row) => {
  if (confirm('确定删除吗？')) {
    tableUser.value.splice(index,1)
  }
}



</script>
<style scoped>
</style>